﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace NearForums.DataAccess
{
    public class AdminMenuDataAccess : BaseDataAccess
    {
        public List<AdminMenu> GetList(int leaveId)
        {
            string commandText = string.Format("SELECT [Id] ,[MenuName] ,[Sort] ,[leaveId]  FROM [AdminMenu] WHER [leaveId]={0}", leaveId);

            var dt = DbHelper.ExecuteDatasetInMasterDB(CommandType.Text, commandText).Tables[0];
            var AdminMenuList = new List<AdminMenu>();

            AdminMenu menu = null;
            foreach (DataRow dr in dt.Rows)
            {
                menu = ParseMenuDataRow(dr);

                AdminMenuList.Add(menu);
            }
            return AdminMenuList;
        }

        protected virtual AdminMenu ParseMenuDataRow(DataRow dr)
        {
            AdminMenu m = new AdminMenu()
            {
                Id = int.Parse(dr.GetString("Id")),
                MenuName = dr.GetString("MenuName"),
                Sort=int.Parse(dr.GetString("Sort")),
                leaveId=int.Parse(dr.GetString("Sort"))
            };
            return m;
        }

    }
}
